package com.m4399.shortcut_test.broadcast

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.m4399.shortcut_test.ShortCutCreateUtil
import com.m4399.shortcut_test.core.helper.ShortcutHelper
import com.m4399.shortcut_test.core.helper.ShortcutHelper.EXTRA_ID
import com.m4399.shortcut_test.core.helper.ShortcutHelper.EXTRA_LABEL


class ShortCurtCreateBroadcastReceiver : BroadcastReceiver() {
    private val TAG ="shortcut"
    override fun onReceive(context: Context, intent: Intent) {
        val action = intent.action

        if (ShortcutHelper.BROADCAST_ACTION == action) {
            val id = intent.getStringExtra(EXTRA_ID)
            val label = intent.getStringExtra(EXTRA_LABEL)

            Log.d(TAG, "创建成功 onReceive: $id --- $label")
            ShortCutCreateUtil.shortCutCreateCallback?.onCreateSuccess()
        }
    }

}